package com.dao.account.impl;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.liwei.ibatisspring.dao.AccountDAO;
import com.liwei.ibatisspring.domain.Account;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:ibatis-spring.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
public class AccountDaoTest {
	private AccountDAO accountDAO;
	private Account a;

	@Autowired
	public void setAccountDAO(AccountDAO accountDAO) {
		this.accountDAO = accountDAO;
	}

	public AccountDaoTest() {
		a = new Account();
		a.setFirstName("test1");
		a.setLastName("test");
		a.setEmailAddress("test");
	}

	@Test
	public void testInsert() {

		Object o = accountDAO.insertAccount(a);

		Account aa = accountDAO.selectAccountById(1);

		System.out.println("tt");
	}
}